﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using COMMON;

namespace PopPromotoraCallCenter
{
    public partial class Principal : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var nIdUsuario = IdUsuario;
                var strPagina = Request.QueryString["pagina"];
                if (Session["nIdUsuario"] == null && nIdUsuario>0)
                {
                    Session["nIdUsuario"] = nIdUsuario;
                    Response.Redirect("~/"+Request.QueryString["pagina"]);
                }
                else if (Session["nIdUsuario"] != null && nIdUsuario > 0)
                {
                    Response.Redirect("~/" + Request.QueryString["pagina"]);
                }
                else
                {
                    Funcao.Alert(this.Page, "Acesso não autorizado!");
                }


            }
        }
       
        private int IdUsuario
        {
            get
            {
                var id = 0;
                if (Request.QueryString["idUsuario"] != null)
                {
                    int.TryParse(Funcao.Decrypt(Request.QueryString["idUsuario"], Configuracao.CRYPTOKEY()), out id);
                }
                return id;
            }
        }
    }
}